package es.uned.ii.si3.exceptions;

public class ObjectNotFoundException extends Exception {

    private Class clazz;
    private Object attribute;
    private Object value;


    public ObjectNotFoundException(String message) {
        super(message);

    }
    public ObjectNotFoundException(Class clazz, Object key) {
        this.clazz = clazz;
        this.value = key;

    }

    public ObjectNotFoundException(Class clazz, Object attribute, Object key) {
        this.clazz = clazz;
        this.attribute = attribute;
        this.value = key;
    }

    public ObjectNotFoundException(ObjectNotFoundException e) {
    }

    public ObjectNotFoundException(Exception e) {
        super(e);
    }

    public String toString() {
        String str = null;
        if(super.getMessage()==null) {
            if(attribute==null) {
                str = super.toString() + ". No se pudo encontrar el objeto de tipo [" +
                    clazz + "] con clave primaria [" + value + "].";
            } else {
                str = super.toString() + ". No se pudo encontrar el objeto de tipo [" +
                    clazz + "] con atributo [" + attribute + "] igual a [" + value + "]";
            }
        } else {
            str = super.getMessage();
        }
        return str;
    }
}
